package com.fjnldx.ks.controller;

import com.fjnldx.ks.mapper.MesForthMapper;
import com.fjnldx.ks.pojo.mesDoMain.*;
import com.fjnldx.ks.pojo.request.GydReq;
import com.fjnldx.ks.pojo.request.GydReq2;
import com.fjnldx.ks.pojo.request.GydReq3;
import com.fjnldx.ks.pojo.response.Result;
import com.fjnldx.ks.pojo.response.Result2;
import com.fjnldx.ks.service.MesForthService;
import com.fjnldx.ks.service.MesSecondService;
import com.fjnldx.ks.utils.Common;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.text.ParseException;


/**
 * @author 11759
 */
@RestController
@RequestMapping("/api-gyd")
@Api(value = "工艺单模块", tags = "工艺单模块")
public class SecondController {
    @Autowired
    MesSecondService mesSecondService;
    @Autowired
    MesForthService mesForthService;
    @Autowired
    MesForthMapper mesForthMapper;
    @Autowired
    Common common;

    @PostMapping("/getAllOrg")
    @ApiOperation(value = "获取所有组织", notes = "Organization")
    public Result mesSc1() {
        Result allOrg = mesSecondService.getOrganization();
        return allOrg;
    }

    @PostMapping("/getAllWorkShop")
    @ApiOperation(value = "获取所有车间", notes = "WorkShop")
    public Result mesSc2() {
        Result workShop = mesSecondService.getWorkShop();
        return workShop;
    }

    @PostMapping("/getAllProcedure")
    @ApiOperation(value = "获取所有工序", notes = "Procedure")
    public Result mesSc3() {
        Result procedure = mesSecondService.getProcedure();
        return procedure;
    }

    @PostMapping("/getAllEquipment")
    @ApiOperation(value = "获取所有设备类型", notes = "Equipment")
    public Result mesSc4() {
        Result equipment = mesSecondService.getEquipment();
        return equipment;
    }

    @PostMapping("/getAllVarieties")
    @ApiOperation(value = "获取所有品种名称", notes = "Varieties")
    public Result mesSc5() {
        Result varieties = mesSecondService.getVarieties();
        return varieties;
    }

    @PostMapping("/getProcessSheet")
    @ApiOperation(value = "查询工艺单变更列表（未完善）", notes = "ProcessSheet")
    public Result mesSc6(@ApiParam(value = "入参JSON") @RequestBody GydReq gydReq) {
        System.out.println(gydReq.toString());
        Result processSheet1 = mesSecondService.getProcessSheet(gydReq);
        return processSheet1;
    }

    @PostMapping("/importExcelToDataBase")
    @ApiOperation(value = "导入工艺单变更Excel（未完善）", notes = "格式（.xls标准文件）")
    public Result mesSc7(@RequestParam("file") MultipartFile file) {
        Result result = mesForthService.uploadExcelFile(file);
        return result;
    }


    @PostMapping("/getMesGyd")
    @ApiOperation(value = "获取工艺单各工序--并条1（'1'）|并条2（'2'）|并条3（'3'）|梳棉（'4'）|细纱（'5'）|粗纱（'6'）", notes = "并条1（'1'）|并条2（'2'）|并条3（'3'）|梳棉（'4'）|细纱（'5'）|粗纱（'6'）")
    public Result2 mesSc15(@ApiParam(value = "入参JSON") @RequestBody GydReq2 gydReq2) {
        Result2 result = mesForthService.getMesGyd(gydReq2);
        return result;
    }

    @PostMapping("/deleteMesGyd")
    @ApiOperation(value = "删除工艺单各工序--并条1（'1'）|并条2（'2'）|并条3（'3'）|梳棉（'4'）|细纱（'5'）|粗纱（'6'）", notes = "并条1（'1'）|并条2（'2'）|并条3（'3'）|梳棉（'4'）|细纱（'5'）|粗纱（'6'）")
    public Result mesSc16(@ApiParam(value = "入参JSON") @RequestBody GydReq3 gydReq3) {
        Result result = mesForthService.deleteMesGyd(gydReq3);
        return result;
    }

    @PostMapping("/upDateMesGydBingTiao1")
    @ApiOperation(value = "更新并条1工艺单", notes = "并条1")
    public Result mesSc17(@ApiParam(value = "入参JSON") @RequestBody MesGydBingtiao1 mesGydBingtiao1) {
        Result result = mesForthService.updateMesGydBingTiao1(mesGydBingtiao1);
        return result;
    }

    @PostMapping("/upDateMesGydBingTiao2")
    @ApiOperation(value = "更新并条2工艺单", notes = "并条2")
    public Result mesSc18(@ApiParam(value = "入参JSON") @RequestBody MesGydBingtiao2 mesGydBingtiao2) {
        Result result = mesForthService.updateMesGydBingTiao2(mesGydBingtiao2);
        return result;
    }

    @PostMapping("/upDateMesGydBingTiao3")
    @ApiOperation(value = "更新并条3工艺单", notes = "并条3")
    public Result mesSc19(@ApiParam(value = "入参JSON") @RequestBody MesGydBingtiao3 mesGydBingtiao3) {
        Result result = mesForthService.updateMesGydBingTiao3(mesGydBingtiao3);
        return result;
    }

    @PostMapping("/upDateMesGydShuMian")
    @ApiOperation(value = "更新梳棉工艺单", notes = "梳棉")
    public Result mesSc20(@ApiParam(value = "入参JSON") @RequestBody MesGydShumian mesGydShumian) {
        Result result = mesForthService.updateMesGydShuMian(mesGydShumian);
        return result;
    }

    @PostMapping("/upDateMesGydXiSha")
    @ApiOperation(value = "更新细纱工艺单", notes = "细纱")
    public Result mesSc21(@ApiParam(value = "入参JSON") @RequestBody MesGydXisha mesGydXisha) {
        Result result = mesForthService.updateMesGydXiSha(mesGydXisha);
        return result;
    }

    @PostMapping("/upDateMesGydCuSha")
    @ApiOperation(value = "更新粗纱工艺单", notes = "粗纱")
    public Result mesSc22(@ApiParam(value = "入参JSON") @RequestBody MesGydChusha mesGydChusha) {
        Result result = mesForthService.updateMesGydCuSha(mesGydChusha);
        return result;
    }

    @PostMapping("/insertMesGydBingTiao1")
    @ApiOperation(value = "插入并条1工艺单", notes = "并条1（id和time可不传）")
    public Result mesSc13(@ApiParam(value = "入参JSON") @RequestBody MesGydBingtiao1 mesGydBingtiao1) throws ParseException {
        Result result = mesForthService.insertMesGydBingTiao1(mesGydBingtiao1);
        return result;
    }

    @PostMapping("/insertMesGydBingTiao2")
    @ApiOperation(value = "插入并条2工艺单", notes = "并条2（id和time可不传）")
    public Result mesSc14(@ApiParam(value = "入参JSON") @RequestBody MesGydBingtiao2 mesGydBingtiao2) throws ParseException {
        Result result = mesForthService.insertMesGydBingTiao2(mesGydBingtiao2);
        return result;
    }

    @PostMapping("/insertMesGydBingTiao3")
    @ApiOperation(value = "插入并条3工艺单", notes = "并条3（id和time可不传）")
    public Result mesSc15(@ApiParam(value = "入参JSON") @RequestBody MesGydBingtiao3 mesGydBingtiao3) throws ParseException {
        Result result = mesForthService.insertMesGydBingTiao3(mesGydBingtiao3);
        return result;
    }

    @PostMapping("/insertMesGydShumian")
    @ApiOperation(value = "插入梳棉工艺单", notes = "梳棉（id和time可不传）")
    public Result mesSc16(@ApiParam(value = "入参JSON") @RequestBody MesGydShumian mesGydShumian) throws ParseException {
        Result result = mesForthService.insertMesGydShumian(mesGydShumian);
        return result;
    }

    @PostMapping("/insertMesGydChuSha")
    @ApiOperation(value = "插入粗纱工艺单", notes = "粗纱（id和time可不传）")
    public Result mesSc17(@ApiParam(value = "入参JSON") @RequestBody MesGydChusha mesGydChusha) throws ParseException {
        Result result = mesForthService.insertMesGydChusha(mesGydChusha);
        return result;
    }

    @PostMapping("/insertMesGydXiSha")
    @ApiOperation(value = "插入细纱工艺单", notes = "细纱（id和time可不传）")
    public Result mesSc18(@ApiParam(value = "入参JSON") @RequestBody MesGydXisha mesGydXisha) throws ParseException {
        Result result = mesForthService.insertMesGydXiSha(mesGydXisha);
        return result;
    }
}